# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
from selenium import webdriver
from pymongo import MongoClient

conn = MongoClient()
co = conn['bilibili']['bb']

class BilibiliPipeline(object):
    def open_spider(self, spider):
        spider.driver = webdriver.Chrome()

    def process_item(self, item, spider):
        co.insert_one(item)
        return item

    def close_spider(self, spider):
        spider.driver.quit()
